package cn.yh.register.cmn.listener;

import cn.yh.register.cmn.mapper.DictMapper;
import cn.yh.register.model.cmn.Dict;
import cn.yh.register.vo.cmn.DictEeVo;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import org.springframework.beans.BeanUtils;

public class ExcelListener extends AnalysisEventListener<DictEeVo> {
    private final DictMapper dictMapper;
    public ExcelListener(DictMapper dictMapper){
        this.dictMapper = dictMapper;
    }

    //每读取一行数据都会执行该方法
    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {
        Dict dict = new Dict();

        BeanUtils.copyProperties(dictEeVo,dict);
        dictMapper.insert(dict);
    }
    //所有数据读取完成后执行该操作
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
